<?php
$params = array_merge(
    require(__DIR__ . '/../../common/config/params.php'),
    require(__DIR__ . '/../../common/config/params-local.php'),
    require(__DIR__ . '/params.php'),
    require(__DIR__ . '/params-local.php')
);

return [
    'id' => 'app-backend',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'backend\controllers',
    'bootstrap' => ['log'],
    'modules' => [],
    
     //yii2-admin 别名
    'aliases' => [    
        '@mdm/admin' => '@vendor/mdmsoft/yii2-admin',
    ],
    
    

    //配置 yii2-admin 模型位置 
     'modules' => [
        'admin' => [        
            'class' => 'mdm\admin\Module',   // @vendor/mdmsoft/yii2-admin
        ],
        //......
    ],
    
 
    'components' => [
        
        'request' => [
            'csrfParam' => '_csrf-backend',
        ],
        'user' => [
            'identityClass' => 'backend\models\User',
            'enableAutoLogin' => true,
        ],

        'session' => [
            // this is the name of the session cookie used for login on the backend
            'name' => 'advanced-backend',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        
        
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        
        //url 美化 
        /*
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
            ],
        ],
        */
   
        //配置 rbac
        'authManager' => [        
            'class' => 'yii\rbac\DbManager',
            'defaultRoles' => ['guest'],    
        ],
        
        
        'i18n' => [  
                'translations' => [  
                    '*' => [  
                        'class' => 'yii\i18n\PhpMessageSource',  
                        'basePath' => '@frontend/messages', // if advanced application, set @frontend/messages  
                        'sourceLanguage' => 'en',  
                        'fileMap' => [  
                            //'main' => 'main.php',  
                        ],  
                    ],  
                ],  
        ],
        
       'assetManager' => [
        'bundles' => [
            'dmstr\web\AdminLteAsset' => [
                'skin' => 'skin-red',
                ],
            
            ],
          
           
        ],
        
        
    ],
    
    //access AccessControl 继承 behavior 通过 行为去控制
    'as access' => [
        'class' => 'mdm\admin\components\AccessControl',
        'allowActions' => [
            'site/login',
            'site/logout',
            'site/index',
            'site/captcha',
            'config/set-theme',
//            '*',
        ]
    ],
    
    'as behavior' => [
        'class' => 'backend\components\PreBehavior',
    ],
    
    'defaultRoute' =>'site',
    
    'params' => $params,
];
